<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <h1>何佳欢已经占领了这个库</h1>
    <!DOCTYPE html>
    <html lang="en">

    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <script src="lizhen.js"></script>
    </head>

    <body>
        <script>
            let list = [
                {
                    "id": 1,
                    "goods_name": "班俏BANQIAO超火ins潮卫衣女士2020秋季新款韩版宽松慵懒风薄款外套带帽上衣",
                    "goods_img": "assets/1.webp",
                    "goods_price": 108,
                    "goods_count": 1,
                },
                {
                    "id": 2,
                    "goods_name": "嘉叶希连帽卫衣女春秋薄款2020新款宽松bf韩版字母印花中长款外套ins潮",
                    "goods_img": "assets/2.webp",
                    "goods_price": 129,
                    "goods_count": 1,
                },
                {
                    "id": 3,
                    "goods_name": "思蜜怡2020休闲运动套装女春秋季新款时尚大码宽松长袖卫衣两件套",
                    "goods_img": "assets/3.webp",
                    "goods_price": 198,
                    "goods_count": 1,
                },
                {
                    "id": 4,
                    "goods_name": "思蜜怡卫衣女加绒加厚2020秋冬装新款韩版宽松上衣连帽中长款外套",
                    "goods_img": "assets/4.webp",
                    "goods_price": 99,
                    "goods_count": 1,
                },
                {
                    "id": 5,
                    "goods_name": "幂凝早秋季卫衣女春秋装韩版宽松中长款假两件上衣薄款ins盐系外套潮",
                    "goods_img": "assets/5.webp",
                    "goods_price": 156,
                    "goods_count": 1,
                },
                {
                    "id": 6,
                    "goods_name": "ME&CITY女装冬季新款针织抽绳休闲连帽卫衣女",
                    "goods_img": "assets/6.webp",
                    "goods_price": 142.8,
                    "goods_count": 1,
                },
                {
                    "id": 7,
                    "goods_name": "幂凝假两件女士卫衣秋冬女装2020年新款韩版宽松春秋季薄款ins潮外套",
                    "goods_img": "assets/7.webp",
                    "goods_price": 219,
                    "goods_count": 2,
                },
                {
                    "id": 8,
                    "goods_name": "依魅人2020休闲运动衣套装女秋季新款秋季韩版宽松卫衣 时尚两件套",
                    "goods_img": "assets/8.webp",
                    "goods_price": 178,
                    "goods_count": 1,
                },
                {
                    "id": 9,
                    "goods_name": "芷臻(zhizhen)加厚卫衣2020春秋季女长袖韩版宽松短款加绒春秋装连帽开衫外套冬",
                    "goods_img": "assets/9.webp",
                    "goods_price": 128,
                    "goods_count": 1,
                },
                {
                    "id": 10,
                    "goods_name": "Semir森马卫衣女冬装2019新款可爱甜美大撞色小清新连帽薄绒女士套头衫",
                    "goods_img": "assets/10.webp",
                    "goods_price": 153,
                    "goods_count": 1,
                }
            ]
            // 定义容器
            let num = 0
            let price150up = []
            let sum = 0
            let final = true


            for (let k in list) {
                // 1.计算商品的数量（结果的类型：number）
                num += list[k].goods_count
                // 2.查询商品单价>150元的商品有哪些（订单对象）
                if (list[k].goods_price > 150) {
                    price150up.push(list[k].goods_name)
                }
                // 5.订单的总价（number）
                sum += list[k].goods_price * list[k].goods_count
                //6.判断该订单是否所有的单笔消费都小于500元
                if (list[k].goods_price * list[k].goods_count > 500) {
                    final = false
                    break
                }
            }
            // 输出
            document.write(`数量为:${num}<br>`)
            document.write(`单价>150的有:${price150up}<br>`)


            // // 2.查询商品单价>150元的商品有哪些（订单对象）
            // for (let k in list) {
            //     if (list[k].goods_price > 150) {
            //         price150up.push(list[k].goods_name)
            //     }
            // }
            // 3.根据商品的单价排序商品的顺序（数组对象）
            // 排序
            for (let i = 0; i < list.length; i++) {
                let min = i
                for (let k in list) {
                    if (list[k].goods_price < list[min].goods_price) {
                        min = k
                    }
                }
                let arr = list[min]
                list[min] = list[i]
                list[i] = arr
            }
            document.write(`单价从低到高依次是：`)
            for (let k in list) {
                document.write(`${list[k].goods_name}<br>`)
            }
            // 4.根据商品的消费价格排序商品的顺序（数组对象）
            for (let i = 0; i < list.length; i++) {
                let min = i
                for (let k in list) {
                    if (list[k].goods_price * list[k].goods_count < list[min].goods_price * list[min].goods_count) {
                        min = k
                    }
                }
                let arr = list[min]
                list[min] = list[i]
                list[i] = arr
            }
            document.write(`消费价格从低到高依次是：`)
            for (let k in list) {
                document.write(`${list[k].goods_name}<br>`)
            }
            document.write(`总价为${sum}<br>`)
            if (final) {
                document.write('所有单笔消费都小于500')
            } else {
                document.write('不是所有单笔消费都小于500')
            }
            // // 5.订单的总价（number）
            // let sum = 0
            // for (let k in list) {
            //     sum += list[k].goods_price * list[k].goods_count
            // }
            // document.write(`总价为${sum}<br>`)
            // //6.判断该订单是否所有的单笔消费都小于500元
            // let final = true
            // for (let k in list) {
            //     if (list[k].goods_price * list[k].goods_count > 500) {
            //         final = false
            //         break
            //     }
            // }
            // if (final) {
            //     document.write('所有单笔消费都小于500')
            // } else {
            //     document.write('不是所有单笔消费都小于500')
            // }
        </script>
    </body>

    </html>
    <script src="./liucy.js"></script>
    <script  src="./hjh.js"></script>
</body>

</html>